#!/bin/bash

echo "参数$1"
if [ $1 ]
then rm -f $1
fi

date >> test1

a=$(cat test1)
echo $a
wc $a
wc << EOF
123
$1
123
EOF
test=$(date)
echo -n 'the time is : ' $test 
#who
 #su -m yechenliang -c "cat test1"

iteam_name=$HOME
echo 
echo "The item, $item_name , does exist"

if [ -e $item_name]
then
	echo 'does exist'
else
	echo 'no exist'
fi
if [ 1 == 1 ]
then
	echo 'ok'
fi

val1=10
if (( $val1 * 2 > 90 ))
then
	echo 100
else
	echo 10
fi

if [[ $USER == r* ]]
then
	echo "hello $USER"
else
	echo i do not know you
fi
b=$2
case  $b in
	rich | aa)
	echo "welcome $b";;
	test)
	echo welcome test;;
	jessica)
	echo welcome jessica;;
esac

for test in aa bb  cc dd 
do
	echo $test
done
echo "last test : $test"
#for test2 in i doni\'t know if "this`ll" work
	for test in I don\'t know if "this'll" work
do
	echo $test2
done

for test in aa "nn cc" dd
do
	echo $test
done

list="aa bb dd ss"
list=$list"qq"
for test in $list
do
	echo $test
done
IFS.OLD=$IFS
IFS=$"\n"
file="test1"
for aa in $(cat $file)
do
	echo $aa
done

#for file in /home/yechenliang/*
#do
#	if [ -d $file ]
#		echo $file is a mulu
#	elif [ -f $file ]
#		echo $file is a wenjian
#	fi
#done

for (( i=1; i <= 10; i++ ))
do
	echo "the $i"
done

for (( a=1, b=10; a <= 10; a++, b-- ))
do
	echo "a : $a, b : $b"
done

val1=10
while [ $val1 -gt 0 ]
do
	echo $val1
	val1=$[ $val1 -1 ]
done
cd /home/yechenliang
touch aa.sh
if [ -f aa.sh ]
then
	echo done
else
	echo no
fi
var1=9
while echo $var1
	[ $var1 -gt 0 ]
do
	echo $var1 >> test1
	var1=$[ $var1 - 1 ]
done

var2=100
until echo $var2
	[ $var2 -eq 0 ]
do
	echo $var2
	var2=$[$var2 - 25 ]
done

for (( c1 = 1; c1 < 3; c1++ ))
do
	echo $c1
	for (( b1 = 4; b1 < 6; b1++ ))
	do
		echo $b1
	done

done
aa=5
while [ $aa -gt 0 ]
do
	echo $aa
	aa=$[ $aa - 1 ]
done
aaa=3
until [ $aaa -eq 0 ]
do
	echo "aaa is $aaa"
	bbb=5
	while [ $bbb -gt 0 ]
	do
		ccc=$(echo "scale=4; $aaa / $bbb" | bc)
		echo "Inner loop:$aaa / $bbb = $ccc"
		bbb=$[ $bbb - 1 ]
	done
	aaa=$[ $aaa - 1 ]
done

IFS.OLD=$IFS
IFS='\n'
for entry in $(cat /etc/passwd)
do
	echo "value is $entry"
	IFS=:
	for value in $entry
	do
		echo "    $value"
	done
done
for var3 in 1 2 3 4 5 6 7
do
	if [ $var3 -eq 5 ]
	then
		break
	fi
	echo $var3
done
for (( a = 1; a < 4; a++ ))
do
	echo $a
	for (( b = 1; b < 100; b++ ))
	do
		if [ $b -eq 5 ]
		then
			break
		fi
		echo "b  is $b"
	done
done
IFS='\n'
for cc in $(cat /etc/passwd)
do
	echo "info is $cc" 
done > test1

echo -e "aa.\nbb"
for file in /home/yechenliang/*
do
    if [ -d "$file" ]
    then
    echo "$file is a directory"
	else
    echo "$file is a file"
    fi
done

input="users.csv"
while IFS=',' read -r userid name
do
	echo "user: $userid ,   name: $name"
done < "$input"


